import { IPSAppDEAction } from './ipsapp-deaction';
import { IPSAppDEActionLogic } from './ipsapp-deaction-logic';
import { IPSAppDELogic } from './ipsapp-delogic';
import { IPSAppDEMethodLogic } from './ipsapp-demethod-logic';
import { IPSAppDataEntity } from './ipsapp-data-entity';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSAppDEMethodLogicImpl extends PSModelObjectImpl implements IPSAppDEMethodLogic, IPSAppDEActionLogic {
  get actionLogicType(): 1 | 0 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 50 | 51 | 52 | 53 | 54 | 55 | 56 {
    return this.M.actionLogicType != null ? this.M.actionLogicType : -1;
  }

  get attachMode(): 'PREPARE' | 'CHECK' | 'BEFORE' | 'AFTER' {
    return this.M.attachMode;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  protected dstpsappdeaction: IPSAppDEAction | null = null;

  getDstPSAppDEAction(): IPSAppDEAction | null {
    if (this.dstpsappdeaction != null) return this.dstpsappdeaction;
    const value = this.M.getDstPSAppDEAction;
    if (value == null) {
      return null;
    }
    this.dstpsappdeaction = this.getDstPSAppDataEntityMust().findPSAppDEAction(value);
    return this.dstpsappdeaction;
  }

  get dstPSAppDEAction(): IPSAppDEAction | null {
    return this.getDstPSAppDEAction();
  }

  getDstPSAppDEActionMust(): IPSAppDEAction {
    const value = this.getDstPSAppDEAction();
    if (value == null) {
      throw new Error('未指定触发目标行为');
    }
    return value;
  }

  protected dstpsappdataentity: IPSAppDataEntity | null = null;

  getDstPSAppDataEntity(): IPSAppDataEntity | null {
    if (this.dstpsappdataentity != null) return this.dstpsappdataentity;
    const value = this.M.getDstPSAppDataEntity;
    if (value == null) {
      return null;
    }
    this.dstpsappdataentity = this.getPSModel4('app.dataentity.IPSAppDataEntity', value, 'getDstPSAppDataEntity') as IPSAppDataEntity;
    return this.dstpsappdataentity;
  }

  get dstPSAppDataEntity(): IPSAppDataEntity | null {
    return this.getDstPSAppDataEntity();
  }

  getDstPSAppDataEntityMust(): IPSAppDataEntity {
    const value = this.getDstPSAppDataEntity();
    if (value == null) {
      throw new Error('未指定目标行为所属实体');
    }
    return value;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psappdelogic: IPSAppDELogic | null = null;

  getPSAppDELogic(): IPSAppDELogic | null {
    if (this.psappdelogic != null) return this.psappdelogic;
    const value = this.M.getPSAppDELogic;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getParentPSModelObject('app.dataentity.IPSAppDataEntity') as IPSAppDataEntity;
    if (ipsappdataentity != null) {
      this.psappdelogic = ipsappdataentity.findPSAppDELogic(value);
    }
    return this.psappdelogic;
  }

  get psAppDELogic(): IPSAppDELogic | null {
    return this.getPSAppDELogic();
  }

  getPSAppDELogicMust(): IPSAppDELogic {
    const value = this.getPSAppDELogic();
    if (value == null) {
      throw new Error('未指定应用实体逻辑');
    }
    return value;
  }

  get scriptCode(): string {
    return this.M.scriptCode;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cloneParam(): boolean {
    return this.M.cloneParam != null ? this.M.cloneParam : false;
  }

  get ignoreException(): boolean {
    return this.M.ignoreException != null ? this.M.ignoreException : false;
  }

  get internalLogic(): boolean {
    return this.M.internalLogic != null ? this.M.internalLogic : false;
  }

  get cls(): string {
    return 'PSAppDEMethodLogicImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.dataentity.IPSAppDEActionLogic' || cls == 'app.dataentity.IPSAppDEMethodLogic' || cls == 'app.dataentity.IPSAppDataEntityObject') return true;
    return super.instanceof(cls);
  }
}
